package com.shierke.Ume.base

import android.app.Activity
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.Window
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import com.shierke.Ume.R

/**
 * Create by Ybx
 * on 2020-09-17
 * Desribe:
 */
open class BaseDialogActivity : BaseActivity() {


    fun setStatusBarTransparentAndFullScreen(activity: Activity, isLightBarText: Boolean = false) {
        val window = activity.window
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setSystemUiVisibility(window)

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
            } else {

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
                    && isLightBarText
                ) {
                    window.decorView.systemUiVisibility =
                        window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
                }
                window.statusBarColor = Color.TRANSPARENT
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setActivityBarVisibility(false)


    }


    private fun setSystemUiVisibility(window: Window) {
        val decorView = window.decorView
        val option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE

        decorView.systemUiVisibility = option
    }

    override fun finish() {
        super.finish()
        this.overridePendingTransition(0, R.anim.report_cause_out)

    }


}